$(function () {
    var user = eval('('+document.cookie.split(";")[0].split("=")[1]+')');
    var id = user.id;
    var tr0 = $("<h4 class=\"panel-title\" id=\"emailsName\">邮件组： "+user.groupName+"  <span id=\"emailsdence\">信息介绍： "+user.groupDesc+"</span></h4>");
    tr0.appendTo($("#emailflog"));
    //邮件组成员查询
    $.ajax({
        type: 'get',
        url: "/email-group/"+id,
        //contentType: 'application/json;charset=utf-8',
        success: function(data){    //请求成功时的回调函数
            if(data.code == "1"){
                var userList=data.data.members;
                for(var i=0;i<userList.length;i++){
                    var user=userList[i];
                    //行
                    var str = $("<tr></tr>");
                    //列
                    var std = $("<th scope=\"row\"></th>");
                    var std1 = $("<td><div></div></td>");
                    var std3 = $("<td><div><span class=\"tag label label-info\">正常</span></div></td>");
                    var std2 = $("<td><button class=\"btn btn-default btn-rounded\" type=\"button\" title=\"删除\" onclick='deleteUser("+user.id+","+id+")'><i class=\" icon-trash \"></i> </button></td>");
                    str.append(std.clone().text(i+1));
                    str.append(std1.clone().text(user.name));
                    str.append(std1.clone().text(user.email));
                    str.append(std1.clone().text(user.createTime));
                    str.append(std3.clone());
                    str.append(std2.clone());
                    str.appendTo($("#tableText"));
                }
                //window.location.href="/user/success";
            }else{
                alert(data.msg + data.data);
            }
        },
    });
    /*//行
    var str = $("<tr></tr>");
    //列
    var std = $("<th scope=\"row\"></th>");
    var std1 = $("<td><div></div></td>");
    var std3 = $("<td><div><span class=\"tag label label-info\">正常</span></div></td>");
    var std2 = $("<td><button class=\"btn btn-default btn-rounded\" type=\"button\" title=\"删除\" onclick='deleteUser("+user.id+")'><i class=\" icon-trash \"></i> </button></td>");
    str.append(std.clone().text(i+1));
    str.append(std1.clone().text(user.name));
    str.append(std1.clone().text(user.email));
    str.append(std1.clone().text(user.createTime));
    str.append(std3.clone());
    str.append(std2.clone());
    str.appendTo($("#tableText"));*/

});
function deleteUser(a,b) {
    var sbj = {};

    var user = {};
    user.id = a;
    var emailGroupInfo = {};
    emailGroupInfo.id = b;

    sbj.user = user;
    sbj.emailGroupInfo = emailGroupInfo;
    alert(a+"aaa"+b);
    $.ajax({
        type: 'post',
        url: "/email-group/remove-member",
        contentType: 'application/json;charset=utf-8',
        data:JSON.stringify(sbj),
        success: function(data){    //请求成功时的回调函数
            if(data.code == "1"){
                alert("删除成功");
                window.location.href="/user/success";
            }else{
                alert(data.msg + data.data);
            }
        },
    });
}